package com.yan.controller;


import com.yan.mapper.Mapper;
import com.yan.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {


    @Autowired
    private Mapper mapper;


    @GetMapping("/all")
    public List<User> abc() {

        List<User> users = mapper.queryAll();
        for (User user : users) {
            System.out.println(user);

        }
        return users;

    }

    @GetMapping("/allid/{id}")
    public User abc(@PathVariable("id")Integer id) {

        return mapper.queryId(id);

    }


    @GetMapping("/delete/{id}")
    public Integer abcs(@PathVariable("id")Integer id) {

        int as = mapper.queryDelete(id);
        return as;

    }

    @GetMapping("addUser")
    public  String add(){
        mapper.queryAdd(new User(6,"闫文","61651"));
        return "ok";
   }

    @GetMapping("aupdateUser")
    public  String update(){
        mapper.queryUpdate(new User(6,"闫111","61651"));
        return "ok11";
    }


}
